
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

public class MyTableModel extends AbstractTableModel
{
    private int columns_count;
    private ArrayList<String> columns_header = new ArrayList<String>();

    //private ArrayList<ArrayList> data = new ArrayList<ArrayList>();
    private List<Object[]> data = new ArrayList<Object[]>();
    public MyTableModel(ArrayList columns_header)
    {  
        this.columns_count = columns_header.size();
        this.columns_header = columns_header;     
        for(int i = 0; i < data.size(); i++)
        {
            data.add(new Object[columns_count]);
        }
    }
    public int getColumnCount()
    {
        return columns_count;
    }
    public int getRowCount()
    {
        return data.size();
    }
    @Override
  public String getColumnName(int column_index) 
  {
        String column_name = columns_header.get(column_index);
        return column_name;
  }
  public Object getValueAt(int row_index, int column_index) 
  {
      Object[] row_data = data.get(row_index);
      Object value = row_data[column_index];
      return value;
  }
  public void setValueAt(Object value, int row_index, int column_index)
  {
        //data.get(row_index).set(column_index, value);
        Object[] row_data = data.get(row_index);
        row_data[column_index] = value;
        fireTableCellUpdated(row_index, column_index);
  }
    public void addRow(Object[] row_values)
    {
        data.add(row_values);
    }
    public void updateValue(){}
}
    

